package xyz.eden.boot.push.adapter.web.reach.controller;

import com.alibaba.fastjson2.JSON;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.eden.boot.push.application.bo.ReachInfoBO;
import xyz.eden.boot.push.application.service.ReachService;

import javax.annotation.Resource;

/**
 * ReachController
 *
 * @author gavin
 * @version 1.0
 * @descriptor
 * @date 2023/7/30 17:51
 */
@Slf4j
@RestController
@RequestMapping(value = "reach")
public class ReachController {

    @Resource
    private ReachService reachService;
    @Resource
    private HttpServletRequest request;


    @GetMapping(value = "{id}")
    public String getReachInfo(@PathVariable(value = "id") Long userId) {
        String token = request.getHeader("token");
        ReachInfoBO bo = reachService.getUserReachInfo(userId);
        String jsonString = JSON.toJSONString(bo);
        log.info("Reach Info: [{}]. token: [{}].", jsonString, token);
        return jsonString;
    }
}
